package com.jerehedu.myapplication34.entrty;

import android.os.Parcel;
import android.os.Parcelable;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

/**
 * book实体类
 * Created by lenovo on 2016/11/3.
 */
@DatabaseTable(tableName = "BookTable")
public class Book implements Parcelable {
    @DatabaseField(generatedId = true)
    private int id;
    @DatabaseField
    private String name;
    @DatabaseField
    private String img;
    @DatabaseField
    private String url;
    //是否为网络数据，1为是
    @DatabaseField
    private int isLocal=1;
    //这是读到的章节数
    @DatabaseField
    private int chapterNum=0;
    //次章节读了多少
    @DatabaseField
    private double progress=0;
    //书籍大小
    @DatabaseField
    private double size;
    //是否被选中,1:选中，0：没选中
    private int isCheck=0;
    //长按数据ImageView的显示
    private int isShow=0;

    public int getIsCheck() {
        return isCheck;
    }

    public void setIsCheck(int isCheck) {
        this.isCheck = isCheck;
    }

    public int getIsShow() {
        return isShow;
    }

    public void setIsShow(int isShow) {
        this.isShow = isShow;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(name);
        dest.writeString(img);
        dest.writeString(url);
        dest.writeInt(isLocal);
        dest.writeInt(chapterNum);
        dest.writeDouble(progress);
        dest.writeDouble(size);
    }

    public static final Parcelable.Creator<Book> CREATOR = new Creator<Book>() {
        @Override
        public Book createFromParcel(Parcel source) {
            Book book = new Book();
            book.setId(source.readInt());
            book.setName(source.readString());
            book.setImg(source.readString());
            book.setUrl(source.readString());
            book.setIsLocal(source.readInt());
            book.setChapterNum(source.readInt());
            book.setProgress(source.readDouble());
            book.setSize(source.readDouble());
            return book;
        }

        @Override
        public Book[] newArray(int size) {
            return new Book[size];
        }
    };

    public Book(Parcel in){
        id=in.readInt();
        name=in.readString();
        img=in.readString();
        url=in.readString();
        isLocal=in.readInt();
        chapterNum=in.readInt();
        progress=in.readDouble();
        size=in.readDouble();
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getIsLocal() {
        return isLocal;
    }

    public void setIsLocal(int isLocal) {
        this.isLocal = isLocal;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }



    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public double getProgress() {
        return progress;
    }

    public void setProgress(double progress) {
        this.progress = progress;
    }

    public int getChapterNum() {
        return chapterNum;
    }

    public void setChapterNum(int chapterNum) {
        this.chapterNum = chapterNum;
    }

    public double getSize() {
        return size;
    }

    public void setSize(double size) {
        this.size = size;
    }

    public Book() {
    }

    public Book(int id, String name, String img, String url, int isLocal, int chapterNum, double progress) {
        this.id = id;
        this.name = name;
        this.img = img;
        this.url = url;
        this.isLocal = isLocal;
        this.chapterNum = chapterNum;
        this.progress = progress;
    }
}
